﻿
namespace NetROS.Tiers.Windows.Forms
{
	/// <summary>
	/// abstract Sifarnik typed datagridview
	/// </summary>
	[System.ComponentModel.DesignerCategoryAttribute("code")]
	public abstract class SifarnikDataGridViewBase : System.Windows.Forms.UserControl
	{	
		/// <summary> 
		/// Thrown when the current Entity changed.
		/// </summary>
		public event System.EventHandler<SifarnikDataGridViewEventArgs> CurrentEntityChanged;
		
		#region Fields
				
		/// <summary> 
		/// the current entity.
		/// </summary>
		private Entities.Sifarnik _currentSifarnik = null;
		//private Dictionary<string, string> _columnsHeaders = new Dictionary<string, string>();
		
		/// <summary> 
		/// the datagridview instance
		/// </summary>
		protected System.Windows.Forms.DataGridView uxSifarnikDataGridView;
		
		/// <summary> 
		/// the errorprovider
		/// </summary>
		protected System.Windows.Forms.ErrorProvider uxSifarnikErrorProvider;
		
		/// <summary> 
		/// the bindingsource
		/// </summary>
		protected System.Windows.Forms.BindingSource uxSifarnikBindingSource;
		
		
		/// <summary> 
		/// the DGV column associated with the ID property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxIDDataGridViewColumn;
		/// <summary> 
		/// the DGV column associated with the IDSifarnikTip property
		/// </summary>
		protected System.Windows.Forms.DataGridViewComboBoxColumn uxIDSifarnikTipDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the Naziv property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxNazivDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the Sifra property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxSifraDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the VrijednostInt property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxVrijednostIntDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the VrijednostReal property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxVrijednostRealDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the VrijednostMoney property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxVrijednostMoneyDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the VrijednostDatum property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxVrijednostDatumDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the VrijednostTekst property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxVrijednostTekstDataGridViewColumn;
		
		#endregion
					
		#region Combo list
		
				
		private Entities.TList<Entities.SifarnikTip> _IDSifarnikTipList;
		
		/// <summary> 
		/// The list of selectable SifarnikTip
		/// </summary>
		[System.ComponentModel.Category("DropDownList BindingSources")]
		public Entities.TList<Entities.SifarnikTip> IDSifarnikTipList
		{
			get {return this._IDSifarnikTipList;}
			set 
			{
				this._IDSifarnikTipList = value;
				this.uxIDSifarnikTipDataGridViewColumn.DataSource = null;
				this.uxIDSifarnikTipDataGridViewColumn.DataSource = this._IDSifarnikTipList;
			}
		}
		
		private bool _allowNewItemInIDSifarnikTipList;
		
		/// <summary> 
		/// Indicates if user can add an item in the list of SifarnikTip
		/// </summary>
		[System.ComponentModel.Category(".netTiers"), System.ComponentModel.Description("Indicates if end user can add a new item in the combobox. an event will be thrown then.")]
		public bool AllowNewItemInIDSifarnikTipList
		{
			get { return _allowNewItemInIDSifarnikTipList;}
			set
			{
				this._allowNewItemInIDSifarnikTipList = value;
				this.uxIDSifarnikTipDataGridViewColumn.DisplayStyle = value ? System.Windows.Forms.DataGridViewComboBoxDisplayStyle.ComboBox : System.Windows.Forms.DataGridViewComboBoxDisplayStyle.DropDownButton;
			}
		}
		
		#endregion
		
		#region Main Datasource
		
		private Entities.TList<Entities.Sifarnik> _SifarnikList;
				
		/// <summary> 
		/// The list of Sifarnik to be displayed in the DGV.
		/// </summary>
		[System.ComponentModel.Category("Data")]
		public Entities.TList<Entities.Sifarnik> SifarnikList
		{
			get {return this._SifarnikList;}
			set
			{
				this._SifarnikList = value;
				this.uxSifarnikBindingSource.DataSource = null;
				this.uxSifarnikBindingSource.DataSource = value;
				this.uxSifarnikDataGridView.DataSource = null;
				this.uxSifarnikDataGridView.DataSource = this.uxSifarnikBindingSource;				
				//this.uxSifarnikBindingSource.ListChanged += new System.ComponentModel.ListChangedEventHandler(uxSifarnikBindingSource_ListChanged);
				this.uxSifarnikBindingSource.CurrentItemChanged += new System.EventHandler(OnSifarnikBindingSourceCurrentItemChanged);
			}
		}
		
		private void OnSifarnikBindingSourceCurrentItemChanged(object sender, System.EventArgs e)
		{
			_currentSifarnik = uxSifarnikBindingSource.Current as Entities.Sifarnik;
			
			if (_currentSifarnik != null)
			{
				_currentSifarnik.Validate();
			}
			//_Sifarnik.Validate();
			OnCurrentEntityChanged();
		}

		//void uxSifarnikBindingSource_ListChanged(object sender, System.ComponentModel.ListChangedEventArgs e)
		//{
			//throw new Exception("The method or operation is not implemented.");
		//}		
		
		#endregion
		
		/// <summary>
		/// Gets the currently selected <c cref="Entities.Sifarnik"/> instance.
		/// </summary>
		public Entities.Sifarnik SelectedSifarnik
		{
			get {return this._currentSifarnik;}
		}
		
		#region other properties
		
		/// <summary>
		/// Gets or sets a value indicating whether you have provided your own data-management operations for the DataGridView control.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public bool VirtualMode
		{
			get {return this.uxSifarnikDataGridView.VirtualMode;}
			set
			{
				this.uxSifarnikDataGridView.VirtualMode = value;
			}
		}
		
		/// <summary>
		/// Gets or sets a value indicating whether the option to add rows is displayed to the user.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public bool AllowUserToAddRows
		{
			get {return this.uxSifarnikDataGridView.AllowUserToAddRows;}
			set {this.uxSifarnikDataGridView.AllowUserToAddRows = value;}
		}
		
		/// <summary>
		/// Gets or sets a value indicating whether the user is allowed to delete rows from the DataGridView.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public bool AllowUserToDeleteRows
		{
			get {return this.uxSifarnikDataGridView.AllowUserToDeleteRows;}
			set {this.uxSifarnikDataGridView.AllowUserToDeleteRows = value;}
		}
		
		/// <summary>
		/// Gets the <c cref="DataGridView"/> instance.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public System.Windows.Forms.DataGridView DataGridView
		{
			get {return this.uxSifarnikDataGridView;}
		}
		
		/// <summary>
		/// Gets a collection that contains all the columns in the control.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]		
		[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Visible)]
		//[System.ComponentModel.EditorAttribute("System.Windows.Forms.Design.DataGridViewColumnCollectionEditor, System.Design", typeof(System.Drawing.Design.UITypeEditor))] 
		public System.Windows.Forms.DataGridViewColumnCollection Columns
		{
			get { return this.uxSifarnikDataGridView.Columns; }
		}
		
		#endregion
		
		/// <summary> 
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.IContainer components = null;
	
		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
		protected override void Dispose(bool disposing)
		{
			if (disposing && (components != null))
			{
				components.Dispose();
			}
			base.Dispose(disposing);
		}
	
		#region Constructor
	
		/// <summary>
		/// Initializes a new instance of the <see cref="SifarnikDataGridViewBase"/> class.
		/// </summary>
		public SifarnikDataGridViewBase()
		{			
			this.components = new System.ComponentModel.Container();			
			
			this.uxSifarnikDataGridView = new System.Windows.Forms.DataGridView();
			this.uxSifarnikBindingSource = new System.Windows.Forms.BindingSource(this.components);
			this.uxSifarnikErrorProvider = new System.Windows.Forms.ErrorProvider(this.components);
			this.uxIDDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxIDSifarnikTipDataGridViewColumn = new System.Windows.Forms.DataGridViewComboBoxColumn();
			this.uxNazivDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxSifraDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxVrijednostIntDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxVrijednostRealDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxVrijednostMoneyDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxVrijednostDatumDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxVrijednostTekstDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			//this.uxIDSifarnikTipBindingSource = new SifarnikTipBindingSource(this.components);
			//((System.ComponentModel.ISupportInitialize)(this.uxIDSifarnikTipBindingSource)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.uxSifarnikDataGridView)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.uxSifarnikBindingSource)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.uxSifarnikErrorProvider)).BeginInit();
			this.SuspendLayout();
						
			// 
			// uxSifarnikErrorProvider
			// 
			this.uxSifarnikErrorProvider.ContainerControl = this;
			this.uxSifarnikErrorProvider.DataSource = this.uxSifarnikBindingSource;						
			// 
			// uxSifarnikDataGridView
			// 
			this.uxSifarnikDataGridView.AutoGenerateColumns = false;
			this.uxSifarnikDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
			this.uxSifarnikDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
		this.uxIDDataGridViewColumn,
		this.uxIDSifarnikTipDataGridViewColumn,
		this.uxNazivDataGridViewColumn,
		this.uxSifraDataGridViewColumn,
		this.uxVrijednostIntDataGridViewColumn,
		this.uxVrijednostRealDataGridViewColumn,
		this.uxVrijednostMoneyDataGridViewColumn,
		this.uxVrijednostDatumDataGridViewColumn,
		this.uxVrijednostTekstDataGridViewColumn			});
			this.uxSifarnikDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
			this.uxSifarnikDataGridView.Location = new System.Drawing.Point(0, 0);
			this.uxSifarnikDataGridView.Name = "uxSifarnikDataGridView";
			this.uxSifarnikDataGridView.Size = new System.Drawing.Size(470, 300);
			this.uxSifarnikDataGridView.TabIndex = 0;	
			this.uxSifarnikDataGridView.BackgroundColor = System.Drawing.Color.WhiteSmoke;
			this.uxSifarnikDataGridView.EnableHeadersVisualStyles = false;
			this.uxSifarnikDataGridView.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.OnSifarnikDataGridViewDataError);
			this.uxSifarnikDataGridView.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.OnSifarnikDataGridViewCellValueNeeded);
			this.uxSifarnikDataGridView.CellValuePushed += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.OnSifarnikDataGridViewCellValuePushed);
			
			//
			// uxIDDataGridViewColumn
			//
			this.uxIDDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxIDDataGridViewColumn.DataPropertyName = "ID";
			this.uxIDDataGridViewColumn.HeaderText = "ID";
			this.uxIDDataGridViewColumn.Name = "uxIDDataGridViewColumn";
			this.uxIDDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxIDDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxIDDataGridViewColumn.ReadOnly = true;		
			//
			// uxIDSifarnikTipDataGridViewColumn
			//
			this.uxIDSifarnikTipDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxIDSifarnikTipDataGridViewColumn.DataPropertyName = "IDSifarnikTip";
			this.uxIDSifarnikTipDataGridViewColumn.HeaderText = "IDSifarnikTip";
			this.uxIDSifarnikTipDataGridViewColumn.Name = "uxIDSifarnikTipDataGridViewColumn";
			this.uxIDSifarnikTipDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxIDSifarnikTipDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxIDSifarnikTipDataGridViewColumn.ReadOnly = false;		
			//
			// uxNazivDataGridViewColumn
			//
			this.uxNazivDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxNazivDataGridViewColumn.DataPropertyName = "Naziv";
			this.uxNazivDataGridViewColumn.HeaderText = "Naziv";
			this.uxNazivDataGridViewColumn.Name = "uxNazivDataGridViewColumn";
			this.uxNazivDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxNazivDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxNazivDataGridViewColumn.ReadOnly = false;		
			//
			// uxSifraDataGridViewColumn
			//
			this.uxSifraDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxSifraDataGridViewColumn.DataPropertyName = "Sifra";
			this.uxSifraDataGridViewColumn.HeaderText = "Sifra";
			this.uxSifraDataGridViewColumn.Name = "uxSifraDataGridViewColumn";
			this.uxSifraDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxSifraDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxSifraDataGridViewColumn.ReadOnly = false;		
			//
			// uxVrijednostIntDataGridViewColumn
			//
			this.uxVrijednostIntDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxVrijednostIntDataGridViewColumn.DataPropertyName = "VrijednostInt";
			this.uxVrijednostIntDataGridViewColumn.HeaderText = "VrijednostInt";
			this.uxVrijednostIntDataGridViewColumn.Name = "uxVrijednostIntDataGridViewColumn";
			this.uxVrijednostIntDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxVrijednostIntDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxVrijednostIntDataGridViewColumn.ReadOnly = false;		
			//
			// uxVrijednostRealDataGridViewColumn
			//
			this.uxVrijednostRealDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxVrijednostRealDataGridViewColumn.DataPropertyName = "VrijednostReal";
			this.uxVrijednostRealDataGridViewColumn.HeaderText = "VrijednostReal";
			this.uxVrijednostRealDataGridViewColumn.Name = "uxVrijednostRealDataGridViewColumn";
			this.uxVrijednostRealDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxVrijednostRealDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxVrijednostRealDataGridViewColumn.ReadOnly = false;		
			//
			// uxVrijednostMoneyDataGridViewColumn
			//
			this.uxVrijednostMoneyDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxVrijednostMoneyDataGridViewColumn.DataPropertyName = "VrijednostMoney";
			this.uxVrijednostMoneyDataGridViewColumn.HeaderText = "VrijednostMoney";
			this.uxVrijednostMoneyDataGridViewColumn.Name = "uxVrijednostMoneyDataGridViewColumn";
			this.uxVrijednostMoneyDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxVrijednostMoneyDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxVrijednostMoneyDataGridViewColumn.ReadOnly = false;		
			//
			// uxVrijednostDatumDataGridViewColumn
			//
			this.uxVrijednostDatumDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxVrijednostDatumDataGridViewColumn.DataPropertyName = "VrijednostDatum";
			this.uxVrijednostDatumDataGridViewColumn.HeaderText = "VrijednostDatum";
			this.uxVrijednostDatumDataGridViewColumn.Name = "uxVrijednostDatumDataGridViewColumn";
			this.uxVrijednostDatumDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxVrijednostDatumDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxVrijednostDatumDataGridViewColumn.ReadOnly = false;		
			//
			// uxVrijednostTekstDataGridViewColumn
			//
			this.uxVrijednostTekstDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxVrijednostTekstDataGridViewColumn.DataPropertyName = "VrijednostTekst";
			this.uxVrijednostTekstDataGridViewColumn.HeaderText = "VrijednostTekst";
			this.uxVrijednostTekstDataGridViewColumn.Name = "uxVrijednostTekstDataGridViewColumn";
			this.uxVrijednostTekstDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxVrijednostTekstDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxVrijednostTekstDataGridViewColumn.ReadOnly = false;		
			//
			// uxIDSifarnikTipDataGridViewColumn
			//				
			this.uxIDSifarnikTipDataGridViewColumn.DisplayMember = "Naziv";	
			this.uxIDSifarnikTipDataGridViewColumn.ValueMember = "ID";	
			this.uxIDSifarnikTipDataGridViewColumn.DisplayStyleForCurrentCellOnly = true;
			//uxIDSifarnikTipDataGridViewColumn.DataSource = uxIDSifarnikTipBindingSource;				
				
			
			// this
			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			this.Controls.Add(this.uxSifarnikDataGridView);
			this.Name = "SifarnikDataGridView";
			this.Size = new System.Drawing.Size(470, 300);
			//((System.ComponentModel.ISupportInitialize)(this.uxIDSifarnikTipBindingSource)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.uxSifarnikErrorProvider)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.uxSifarnikDataGridView)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.uxSifarnikBindingSource)).EndInit();
			this.ResumeLayout(false);
		}
		#endregion
				
		#region events
		
		/// <summary>
		/// Raised the CurrentEntityChanged event.
		/// </summary>
		protected void OnCurrentEntityChanged()
		{
			if (CurrentEntityChanged != null)
			{
				SifarnikDataGridViewEventArgs args = new SifarnikDataGridViewEventArgs();
				args.Sifarnik = _currentSifarnik;
				CurrentEntityChanged(this, args); 
			}
		}
		
		#endregion
		
		/// <summary>
		/// Strongly typed event 
		/// </summary>
		public class SifarnikDataGridViewEventArgs : System.EventArgs
		{
			private Entities.Sifarnik	_Sifarnik;
	
			/// <summary>
			/// the  Entities.Sifarnik instance.
			/// </summary>
			public Entities.Sifarnik Sifarnik
			{
				get { return _Sifarnik; }
				set { _Sifarnik = value; }
			}	
		}
		
		/// <summary>
		/// Handles the DataError event of the uxSifarnikDataGridView control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="T:System.Windows.Forms.DataGridViewDataErrorEventArgs"/> instance containing the event data.</param>
		protected void OnSifarnikDataGridViewDataError(object sender, System.Windows.Forms.DataGridViewDataErrorEventArgs e)
		{
			System.Diagnostics.Debug.WriteLine(string.Format( "{0}, {1}", e.ColumnIndex, e.RowIndex));
		}
		
		/// <summary>
		/// Handles the CellValueNeeded event of the uxSifarnikDataGridView control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="T:System.Windows.Forms.DataGridViewCellValueEventArgs"/> instance containing the event data.</param>
		protected void OnSifarnikDataGridViewCellValueNeeded(object sender, System.Windows.Forms.DataGridViewCellValueEventArgs e)
		{
			switch(uxSifarnikDataGridView.Columns[e.ColumnIndex].Name)
			{
					case "uxIDDataGridViewColumn":
						e.Value = SifarnikList[e.RowIndex].ID;
						break;
					case "uxIDSifarnikTipDataGridViewColumn":
						e.Value = SifarnikList[e.RowIndex].IDSifarnikTip;
						break;
					case "uxNazivDataGridViewColumn":
						e.Value = SifarnikList[e.RowIndex].Naziv;
						break;
					case "uxSifraDataGridViewColumn":
						e.Value = SifarnikList[e.RowIndex].Sifra;
						break;
					case "uxVrijednostIntDataGridViewColumn":
						e.Value = SifarnikList[e.RowIndex].VrijednostInt;
						break;
					case "uxVrijednostRealDataGridViewColumn":
						e.Value = SifarnikList[e.RowIndex].VrijednostReal;
						break;
					case "uxVrijednostMoneyDataGridViewColumn":
						e.Value = SifarnikList[e.RowIndex].VrijednostMoney;
						break;
					case "uxVrijednostDatumDataGridViewColumn":
						e.Value = SifarnikList[e.RowIndex].VrijednostDatum;
						break;
					case "uxVrijednostTekstDataGridViewColumn":
						e.Value = SifarnikList[e.RowIndex].VrijednostTekst;
						break;
				default:
				break;
			}
		}
		
		/// <summary>
		/// Handles the CellValuePushed event of the uxSifarnikDataGridView control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="T:System.Windows.Forms.DataGridViewCellValueEventArgs"/> instance containing the event data.</param>
		protected void OnSifarnikDataGridViewCellValuePushed(object sender, System.Windows.Forms.DataGridViewCellValueEventArgs e)
		{
			switch(uxSifarnikDataGridView.Columns[e.ColumnIndex].Name)
			{
					case "uxIDDataGridViewColumn":
						SifarnikList[e.RowIndex].ID = (System.Int32)e.Value;
						break;
					case "uxIDSifarnikTipDataGridViewColumn":
						SifarnikList[e.RowIndex].IDSifarnikTip = (System.Int32)e.Value;
						break;
					case "uxNazivDataGridViewColumn":
						SifarnikList[e.RowIndex].Naziv = (System.String)e.Value;
						break;
					case "uxSifraDataGridViewColumn":
						SifarnikList[e.RowIndex].Sifra = (System.String)e.Value;
						break;
					case "uxVrijednostIntDataGridViewColumn":
						SifarnikList[e.RowIndex].VrijednostInt = (System.Int32?)e.Value;
						break;
					case "uxVrijednostRealDataGridViewColumn":
						SifarnikList[e.RowIndex].VrijednostReal = (System.Single?)e.Value;
						break;
					case "uxVrijednostMoneyDataGridViewColumn":
						SifarnikList[e.RowIndex].VrijednostMoney = (System.Decimal?)e.Value;
						break;
					case "uxVrijednostDatumDataGridViewColumn":
						SifarnikList[e.RowIndex].VrijednostDatum = (System.DateTime?)e.Value;
						break;
					case "uxVrijednostTekstDataGridViewColumn":
						SifarnikList[e.RowIndex].VrijednostTekst = (System.String)e.Value;
						break;
				default:
				break;
			}
		}
	}
}
